<script>

function resetTabs()
{
  chrome.tabs.query({status: "complete"}, function (tab)
  {
    var activeTab = null;

    // first, disable all inactive tabs
    for(var i = 0; i < tab.length; i++)
    {
      if(tab[i].active)
      {
        activeTab = tab[i].id;
      }
      else
      {
        chrome.tabs.executeScript(tab[i].id, {code: 'setInactive(true);'});
      }
    }
    
    // second, enable activated tab
    if(activeTab != null)
    {
      chrome.tabs.executeScript(activeTab, {code: 'restoreCurrentLanguage();setInactive(false);'});
    }
  });
}


if(typeof(chrome.tabs.onActivated) == "undefined")
{
  chrome.tabs.onActiveChanged.addListener(
  function(tabId, info)
  {
    resetTabs();
  });
}
else
{
  chrome.tabs.onActivated.addListener(
  function(info)
  {
    resetTabs();
  });
}

</script>
